package main

import (
	"core/cmd/operate"
	"core/cmd/version"
	"fmt"
	"github.com/spf13/cobra"
	"os"
	"os/signal"
)

func main() {
	fmt.Printf(version.CatCoinVersion)
	var cat = &cobra.Command{Use: "catcoin"}
	cat.AddCommand(commands()...)
	cat.Execute()
	c := make(chan os.Signal)
	signal.Notify(c, os.Interrupt, os.Kill)
	<-c
}

func commands() (cls []*cobra.Command) {

	var balance = &cobra.Command{
		Use:   "balance",
		Short: "get cat coin balance",
		Run:   operate.Balance,
	}
	cls = append(cls, balance)

	var chain = &cobra.Command{
		Use:   "chain",
		Short: "get cat coin chain",
		Run:   operate.Chain,
	}
	cls = append(cls, chain)

	var transaction = &cobra.Command{
		Use: "transaction",
		Run: operate.Transaction,
	}
	cls = append(cls, transaction)

	var wallet = &cobra.Command{
		Use: "wallet",
		Run: operate.Wallet,
	}
	cls = append(cls, wallet)

	var send = &cobra.Command{
		Use: "send",
		Run: operate.Send,
	}
	cls = append(cls, send)

	var address = &cobra.Command{
		Use: "address",
		Run: operate.Address,
	}
	cls = append(cls, address)
	return
}
